//Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using NUnit.Framework;

namespace Microsoft.Office.OneNote.UnitTests
{
    /// <summary>
    /// Tests the Page class.
    /// </summary>
    [TestFixture]
    public class PageTest
    {
        [SetUp]
        public void Init()
        {
            NotebookRoot root = OneNote.Application.NotebookRoot;

            // Let's create a new notebook:
            Notebook testNotebook = TestUtils.CreateEmptyNotebook();

            // To that notebook, let's create a new section:
            using (HierarchyTransaction addGroup = new HierarchyTransaction(testNotebook))
            {
                this.testSection = new Section("test section");
                testNotebook.AppendChild(testSection);
                
            }

            //now add a page
            using (HierarchyTransaction createPage = new HierarchyTransaction(testSection))
            {
                this.testPage  = new Page("Test Page");
                this.testSection.AppendChild(testPage );
            }
        }

        [TearDown]
        public void Dispose()
        {
            TestUtils.CloseAndDeleteNotebook((Notebook)this.testSection.Parent);
            this.testSection = null;
            this.testPage = null;
        }

        [Test]
        public void Construction()
        {
        }

        [Test]
        public void CanContain()
        {
            Assert.IsTrue(this.testSection.CanContain(new Page()));
            Assert.IsFalse(this.testSection.CanContain(new Section()));
            Assert.IsFalse(this.testSection.CanContain(new SectionGroup()));
            Assert.IsFalse(this.testSection.CanContain(new Notebook()));
            Assert.IsFalse(this.testSection.CanContain(OneNote.Application.NotebookRoot));
        }

        private Section testSection = null;
        private Page testPage = null;
    }
}